package com.bishe.bishe.dao.mapper;

import com.bishe.bishe.pojo.Customer;
import com.bishe.bishe.pojo.Orders;
import com.bishe.bishe.pojo.User;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface CustomerMapper extends Mapper<Customer> {
    @Select("select * from customer where customer_id=#{customerId}")
    @Results({
            @Result(property = "customerId",column = "customer_id"),
            @Result(property = "customerNumber",column = "customer_number"),
            @Result(property = "customerName",column = "customer_name"),
            @Result(property = "customerLocation",column = "customer_location"),
            @Result(property = "customerPwd",column = "customer_pwd")
    })
    Customer findall(Integer customerId) ;
    @Select("select * from customer where customer_number=#{customerNumber} ")
    Customer findByNumber(String customerNumber);

    @Select("select * from customer where customer_number=#{customerNumber} and customer_pwd=#{customerPwd} ")
    @Options(useGeneratedKeys=true, keyProperty="customerId", keyColumn="customer_id")
    Customer findCustomer(Customer customer);

    @Select("SELECT * FROM customer WHERE TO_DAYS( NOW( ) ) - TO_DAYS( customer_date) <= 1")
    List<Customer> count();

    @Select("select * from customer ")
    @Results({
            @Result(property = "customerId",column = "customer_id"),
            @Result(property = "customerNumber",column = "customer_number"),
            @Result(property = "customerName",column = "customer_name"),
            @Result(property = "customerLocation",column = "customer_location"),
            @Result(property = "customerPwd",column = "customer_pwd")
    })
    List<Customer> findall1() ;

    @Select("select * from customer where customer_number=#{customerNumber} ")
    @Results({
            @Result(property = "customerId",column = "customer_id"),
            @Result(property = "customerNumber",column = "customer_number"),
            @Result(property = "customerName",column = "customer_name"),
            @Result(property = "customerLocation",column = "customer_location"),
            @Result(property = "customerPwd",column = "customer_pwd")
    })
    Customer findCustomer1(@Param("customerNumber") String customerNumber);
}
